home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / STRINGS / PACKAGE6 / LEFT.DOC < prev    next >
Text File  |  1990-07-25  |  2KB  |  56 lines

  1. ------------------------------------------------------------------------------
  2. LeftString
  3. ------------------------------------------------------------------------------
  4.  
  5. declaration:     procedure LeftString (    OriginalString:
  6.                                              TypeString;
  7.                                            NumberOfChracters:
  8.                                              integer;
  9.                                        var ResultString:
  10.                                              TypeString);
  11.  
  12. purpose:         Returns a portion of a string(original) in another
  13.                  string(result).
  14.  
  15. preconditions:   OriginalString was originally initiialized.
  16.                  NumberOfCharacters has been a given a meaningfull value.
  17.                  ResultString may be undefined.
  18.  
  19. postconditions:  ResultString is filled with the desired number of characters
  20.                  from the original string from left to right starting at far
  21.                  left.
  22.  
  23. special cases:  -if NumberOfCharacters = OriginalString._Length then
  24.                  ResultString = OriginalString.
  25.                 -if NumberOfCharacters > OriginalString._Length then
  26.                  ResultString = OriginalString.
  27.                 -if NumberOfCharacters <= 0 then ResultString._Length = 0 and
  28.                  the ResultString._PackedArray is not changed.
  29.  
  30. example:        var
  31.                   OriginalString,
  32.                   ResultString:
  33.                     TypeString;
  34.                   NumberOfCharacters:
  35.                     integer;
  36.                   LastKey:
  37.                     TypeKey;
  38.  
  39.                 begin
  40.                   .
  41.                   .
  42.                   .
  43.                   ReadlnString (OriginalString, MaxStringLength, LastKey);
  44.                   NumberOfCharacters := 5;
  45.                   LeftString (OriginalString, NumberOfCharacters,
  46.                     ResultString);
  47.                   write(output,'The first five letters are ');
  48.                   WriteString(ResultString);
  49.                   writeln(output,'.')
  50.                   .
  51.                   .
  52.                   .
  53.                 end
  54.  
  55. ------------------------------------------------------------------------------
  56.